﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;
using System.Security.Cryptography;

/// <summary>
///LoginClass 的摘要说明
/// </summary>
public class LoginClass
{
	public LoginClass()
	{
		//
		//TODO: 在此处添加构造函数逻辑
		//
	}

    //该函数将查询用户的登录密码。
    //通过“@”判断用户是通过用户名还是邮箱名登陆，从而进行不同的函数调用取回密码。返回bool类型的判断结果。
    /// <summary>
    /// 查询用户的登陆密码
    /// </summary>
    /// <param name="strLoginName">用户输入的用户名或邮箱</param>
    /// <param name="strPassword">用户输入的密码</param>
    /// <returns></returns>
    public static User VerifyPassword(string strLoginName, string strPassword)
    {
        //要返回的对象bool类Result
		return User.LogIn(strLoginName, strPassword);
		//bool m_bResult;

		////构造SQL语句
		//string[] att = { "PassWord" };
        
		////判断输入的是用户名还是邮箱
		//string cond;
		//string table;
		//if (strLoginName.Contains("@"))
		//{
		//    cond = "UserName=" + strLoginName;
		//    table = "PassWord";
		//}    
		//else 
		//{
		//    cond = "PassWord.UserName = User.UserName AND passWord.UserName = " + strLoginName;
		//    table = "PassWord,User";
		// }
        
		//DataTable dt = DataBaseClass.selectData(att, cond, table, DataBaseClass.GetConnectionString());
        
		//MD5 md5 = new MD5CryptoServiceProvider();
		//byte[] data = System.Text.Encoding.Default.GetBytes(dt.Rows[0]["PassWord"].ToString());//将字符编码为一个字节序列 
		//byte[] md5data = md5.ComputeHash(data);//计算data字节数组的哈希值 
 
        
		//if (dt.Rows.Count == 0)
		//    m_bResult = false;
		//else if (md5.ToString() == strPassword)
		//    m_bResult = true;
		//else m_bResult = false;

        //return m_bResult;
 
    }
}